package com.wpzf.ndhc.controller;

import com.wpzf.common.core.utils.ServletUtils;
import com.wpzf.common.core.web.domain.AjaxResult;
import com.wpzf.common.log.annotation.Log;
import com.wpzf.common.log.enums.BusinessType;
import com.wpzf.common.security.service.TokenService;
import com.wpzf.ndhc.service.*;
import com.wpzf.system.api.model.LoginUser;
import com.wpzf.zxhc.utils.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wpzfndhc/hcdw")
public class WpzfNdhcHcdwController {

    @Autowired
    WpzfNdhcHcdwService wpzfNdhcHcdwService;

    @Autowired
    WpzfNdhcCommonService wpzfNdhcCommonService;

    @Autowired
    TokenService tokenService;

    @Autowired
    WpzfNdhcTbhcjgService wpzfNdhcTbhcjgService;

    @Autowired
    WpzfNdhcJlHcTaskService wpzfNdhcJlHcTaskService;

    @Autowired
    WpzfNdhcShTbService wpzfNdhcShTbService;

    @Value("${tempath}")
    public String tempath;

    /*获取未完成任务列表*/
    @Log(title = "获取当前用户未完成任务(分页)", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/query_unit_w_task", method = RequestMethod.POST)
    public AjaxResult query_unit_w_task(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());

        //获取未完成任务列表
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.query_unit_w_task(parm);
        Integer cnt = wpzfNdhcHcdwService.query_unit_w_task_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取未完成任务列表成功", rest, cnt);
        }
        return AjaxResult.error("获取未完成任务列表失败", -1);
    }

    //获取当前用户未完成任务所有省份
    @Log(title = "获取当前用户未完成任务所有省份", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/query_wwc_Provs", method = RequestMethod.POST)
    public AjaxResult query_wwc_Provs(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.query_wwc_Provs(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前未完成任务用户所有省份表成功", rest);
        }
        return AjaxResult.error("获取当前用户未完成任务所有省份失败", -1);
    }

    //获取当前用户未完成任务所有区县
    @Log(title = "获取当前用户未完成任务所有区县", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/query_wwc_Citys", method = RequestMethod.POST)
    public AjaxResult query_wwc_Citys(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());

        List<Map<String, Object>> rest = wpzfNdhcHcdwService.query_wwc_Citys(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户未完成任务所有区县成功", rest);
        }
        return AjaxResult.error("获取当前用户未完成任务所有区县失败", -1);
    }

    //获取当前用户未完成任务所有图斑
    @Log(title = "获取当前用户未完成任务所有图斑", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/query_unit_wtask_list", method = RequestMethod.POST)
    public AjaxResult query_unit_wtask_list(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.query_unit_wtask_list(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户未完成任务所有图斑成功", rest);
        }

        return AjaxResult.error("获取当前用户未完成任务所有图斑失败", -1);
    }

    //获取当前用户已完成任务所有图斑
    @Log(title = "获取当前用户已完成任务所有图斑", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/query_unit_ytask_list", method = RequestMethod.POST)
    public AjaxResult query_unit_ytask_list(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.query_unit_ytask_list(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户已完成任务所有图斑成功", rest);
        }

        return AjaxResult.error("获取当前用户已完成任务所有图斑失败", -1);
    }

    /*获取已完成任务列表*/
    @Log(title = "获取已完成任务列表", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/query_unit_y_task", method = RequestMethod.POST)
    public AjaxResult query_unit_y_task(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());

        //获取未完成任务列表
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.query_unit_y_task(parm);
        Integer cnt = wpzfNdhcHcdwService.query_unit_y_task_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取已完成任务列表成功*******", rest, cnt);
        }

        return AjaxResult.error("获取已完成任务列表失败", -1);
    }

    //获取当前用户已完成任务所有省份
    @Log(title = "获取当前用户已完成任务所有省份", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/query_ywc_Provs", method = RequestMethod.POST)
    public AjaxResult query_ywc_Provs(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.query_ywc_Provs(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前未完成任务用户所有省份表成功", rest);
        }
        return AjaxResult.error("获取当前用户未完成任务所有省份失败", -1);
    }

    //获取当前用户已完成任务所有区县
    @Log(title = "获取当前用户已完成任务所有区县", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/query_ywc_Citys", method = RequestMethod.POST)
    public AjaxResult query_ywc_Citys(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());

        List<Map<String, Object>> rest = wpzfNdhcHcdwService.query_ywc_Citys(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户已完成任务所有区县成功", rest);
        }
        return AjaxResult.error("获取当前用户已完成任务所有区县失败", -1);
    }

    /*提交核查结果*/
    @Log(title = "提交核查结果", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/updateSubmit", method = RequestMethod.POST)
    public AjaxResult updateSubmit(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date1 = new Date();
        String currentTime = dateFormat.format(date1);
        parm.put("sftj", "是");
        parm.put("sftj_submitdate", currentTime);
        int strTaskCount = wpzfNdhcHcdwService.getTBCount(parm); //获取当前行政区图斑总量
        int strResultCount = wpzfNdhcHcdwService.getTbhcjglist(parm);

        if (strTaskCount != strResultCount) {
            return AjaxResult.error("请核实当前区县是否已核查完成！", -1);
        } else {

            int rest = wpzfNdhcHcdwService.updateSubmit(parm);
            if (rest > 0) {
                List<Map<String, Object>> tbbhList = wpzfNdhcCommonService.getTbbhList(parm);
                if (tbbhList.size() > 0) {
                    for (Map<String, Object> m : tbbhList) {
                        ModelMap map = new ModelMap();
                        map.put("tbbh", m.get("tbbh") + "");
                        map.put("pch", parm.get("pch") + "");
                        map.put("xzqdm", parm.get("xzqdm") + "");
                        map.put("year", parm.get("year") + "");
                        Map<String, Object> model = wpzfNdhcJlHcTaskService.query_tbbh_id(map);
                        if (model != null) {
                            wpzfNdhcJlHcTaskService.deleteTbbh(map); //添加监理任务
                        }
                        //查看该监理任务是否属于扣除类
                        List<Map<String, Object>> kc = wpzfNdhcJlHcTaskService.query_tbbhsfkc(map);
                        if (kc != null && kc.size() > 0) {
                            map.put("jl_sfkc", "1");
                        } else {
                            map.put("jl_sfkc", "0");
                        }
                        wpzfNdhcJlHcTaskService.addTask(map); //添加监理任务
                    }
                }
                return AjaxResult.success("提交成功", rest);
            }
        }
        return AjaxResult.error("提交失败", -1);
    }


    /*获取当前用户所有已完成的任务*/
    @Log(title = "获取当前用户所有已完成的任务", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_user_y_static", method = RequestMethod.POST)
    public AjaxResult get_unit_user_y_static(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_user_y_static(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_user_y_static_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户所有已完成的任务列表成功", rest, cnt);
        }
        return AjaxResult.error("获取当前用户所有已完成的任务失败", -1);
    }

    /*获取当前用户所有未完成的任务*/
    @Log(title = "获取当前用户所有未完成的任务", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_user_w_static", method = RequestMethod.POST)
    public AjaxResult get_unit_user_w_static(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_user_w_static(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_user_w_static_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户所有未完成的任务列表成功", rest, cnt);
        }
        return AjaxResult.error("获取当前用户所有未完成的任务失败", -1);
    }

    /*获取当前用户所有待确认任务*/
    @Log(title = "获取当前用户所有待确认任务", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_dqr_static", method = RequestMethod.POST)
    public AjaxResult get_unit_dqr_static(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_dqr_static(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_dqr_static_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户所有待确认任务列表成功", rest, cnt);
        }
        return AjaxResult.error("获取当前用户所有待确认任务失败", -1);
    }


    //用户提交待确认图斑
    @Log(title = "用户提交待确认图斑", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/update_unit_dqr_submit", method = RequestMethod.POST)
    public AjaxResult update_unit_dqr_submit(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());

        String tbbhs = parm.get("tbbhs") + "";
        int rest = 0;
        if (tbbhs != null && !tbbhs.equals("") && !tbbhs.equals("null") && !tbbhs.equals("|")) {

            String[] list = tbbhs.split("\\|");
            if (list.length > 0) {
                for (int i = 0; i < list.length; i++) {
                    String tbbh = list[i];

                    ModelMap item = new ModelMap();
                    item.put("tbbh", tbbh);
                    item.put("pch", parm.get("pch") + "");
                    item.put("sftj", "是");
                    item.put("sftj_submitdate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime()));
                    item.put("xzqdm", parm.get("xzqdm") + "");
                    item.put("username", loginUser.getUsername());
                    item.put("ywhj", "2");
                    //修改核查结果任务
                    if (wpzfNdhcCommonService.updateHcjg_sftj(item) > 0) {

                        ModelMap sh_item = new ModelMap();
                        sh_item.put("tbbh", tbbh);
                        sh_item.put("pch", parm.get("pch") + "");
                        sh_item.put("sftj", "是");
                        sh_item.put("sftj_submitdate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime()));
                        sh_item.put("xzqdm", parm.get("xzqdm") + "");
                        sh_item.put("username", loginUser.getUsername());
                        sh_item.put("realname", loginUser.getSysUser().getNickName());
                        sh_item.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                        Map<String, Object> model = wpzfNdhcTbhcjgService.query_thjg_ywhj_id(item);
                        if (model != null) {
                            sh_item.put("jl_jljgqr", model.get("jl_jljgqr") + "");
                            String jl_jljgqr = model.get("jl_jljgqr") + "";//获取结果
                            if (jl_jljgqr.equals("同意")) {
                                sh_item.put("ywhj", "1");
                            } else {
                                sh_item.put("ywhj", "0");
                            }
                        }


                        Map<String, Object> tbbhModel = wpzfNdhcShTbService.querybytbbh(sh_item);
                        if (tbbhModel != null) {
                            wpzfNdhcShTbService.deleteTb(sh_item);
                        }
                        sh_item.put("adddate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime()));

                        wpzfNdhcShTbService.addShTb(sh_item);
                        rest++;
                    }
                }
            }
        }

        if (rest > 0) {
            return AjaxResult.success("批量提交成功，成功提交******" + rest + "个******图斑");
        }
        return AjaxResult.error("批量提交失败", -1);
    }

    //获取当前用户所有省份
    @RequestMapping(value = "/queryProvs", method = RequestMethod.POST)
    public AjaxResult queryProvs(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.queryProvs(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户所有省份表成功", rest);
        }

        return AjaxResult.error("获取当前用户所有省份失败", -1);
    }

    //获取当前用户所有区县
    @RequestMapping(value = "/queryCitys", method = RequestMethod.POST)
    public AjaxResult queryCitys(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());

        List<Map<String, Object>> rest = wpzfNdhcHcdwService.queryCitys(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户所有区县成功", rest);
        }

        return AjaxResult.error("获取当前用户所有区县失败", -1);
    }

    /*获取当前用户所有已确认任务*/
    @Log(title = "获取当前用户所有已确认任务", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_yqr_static", method = RequestMethod.POST)
    public AjaxResult get_unit_yqr_static(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_yqr_static(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_yqr_static_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户所有已确认任务列表成功", rest, cnt);
        }
        return AjaxResult.error("获取当前用户所有已确认任务失败", -1);
    }

    //获取当前用户所有省份
    @RequestMapping(value = "/query_yqr_Provs", method = RequestMethod.POST)
    public AjaxResult query_yqr_Provs(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.query_yqr_Provs(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户所有省份表成功", rest);
        }
        return AjaxResult.error("获取当前用户所有省份失败", -1);
    }

    //获取当前用户所有区县
    @RequestMapping(value = "/query_yqr_Citys", method = RequestMethod.POST)
    public AjaxResult query_yqr_Citys(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());

        List<Map<String, Object>> rest = wpzfNdhcHcdwService.query_yqr_Citys(parm);
        if (rest != null) {
            return AjaxResult.success("获取当前用户所有区县成功", rest);
        }
        return AjaxResult.error("获取当前用户所有区县失败", -1);
    }

    /*根据用户名进行任务情况统计*/
    @Log(title = "根据用户名进行任务情况统计", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_usertask_static", method = RequestMethod.POST)
    public AjaxResult get_usertask_static(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("user_name", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_usertask_static(parm);
        Integer cnt = wpzfNdhcHcdwService.get_usertask_static_count(parm);
        if (rest != null) {
            return AjaxResult.success("根据用户名进行任务情况统计成功", rest, cnt);
        }
        return AjaxResult.error("根据用户名进行任务情况统计失败", -1);
    }



    /*单位负责人***************所有批次*/
    @RequestMapping(value = "/get_unit_pchlist", method = RequestMethod.POST)
    public AjaxResult get_unit_pchlist(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_pchlist(parm);
        if (rest != null) {
            return AjaxResult.success("获取单位所有批次成功", rest);
        }

        return AjaxResult.error("获取单位所有批次失败", -1);
    }
    @RequestMapping(value = "/get_unit_prov", method = RequestMethod.POST)
    public AjaxResult get_unit_prov(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_prov(parm);
        if (rest != null) {
            return AjaxResult.success("获取任务管理的省份列表成功", rest);
        }

        return AjaxResult.error("获取任务管理的省份列表失败", -1);
    }

    @RequestMapping(value = "/get_unit_city", method = RequestMethod.POST)
    public AjaxResult get_unit_city(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_city(parm);
        if (rest != null) {
            return AjaxResult.success("获取任务管理的行政区列表成功", rest);
        }
        return AjaxResult.error("获取任务管理的行政区列表失败", -1);
    }

    @Log(title = "单位负责人***************任务管理", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_tasklist", method = RequestMethod.POST)
    public AjaxResult get_unit_tasklist(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_tasklist(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_tasklist_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取任务管理列表成功", rest, cnt);
        }
        return AjaxResult.error("获取任务管理列表失败", -1);
    }
    @Log(title = "单位负责人***************未分配的任务区县", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_wfp_tasklist", method = RequestMethod.POST)
    public AjaxResult get_unit_wfp_tasklist(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_wfp_tasklist(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_wfp_tasklist_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取未分配的任务区县列表成功", rest, cnt);
        }

        return AjaxResult.error("获取未分配的任务区县列表失败", -1);
    }

    @Log(title = "单位负责人***************任务分配用户", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/add_pf_user", method = RequestMethod.POST)
    public AjaxResult add_pf_user(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getUsername());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        parm.put("realname", loginUser.getSysUser().getNickName());
        String fpsj = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss").format(new Date());
        parm.put("fpsj", fpsj);

        int rest = wpzfNdhcHcdwService.add_pf_user(parm);
        if (rest > 0) {
            return AjaxResult.success("任务分配用户成功", rest);
        }
        return AjaxResult.error("任务分配用户失败", -1);
    }
    /*统计核查单位当前的核查进度*/
    @Log(title = "单位负责人***************进度管理 按照区县", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_static", method = RequestMethod.POST)
    public AjaxResult get_unit_static(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_static(param);
        Integer cnt = wpzfNdhcHcdwService.get_unit_static_count(param);
        if (rest != null) {
            return AjaxResult.success("统计核查单位当前的核查进度统计成功", rest, cnt);
        } else{
            return AjaxResult.error("统计核查单位当前的核查进度统计失败", -1);
        }
    }
    /*单位负责人***************统计本单位核查人员进度情况*/
    @Log(title = "单位负责人***************进度管理 按照人员", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_static_user", method = RequestMethod.POST)
    public AjaxResult get_unit_static_user(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_static_user(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_static_user_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取本单位核查人员进度情况列表成功", rest, cnt);
        } else{
            return AjaxResult.error("获取本单位核查人员进度情况列表失败", -1);
        }
    }

    /*单位负责人***************任务批量调整*/
    @Log(title = "单位负责人***************任务批量调整", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/update_tasklist_user", method = RequestMethod.POST)
    public AjaxResult update_tasklist_user(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        String strXzqdmList = parm.get("xzqdmlist") + "";
        String msg = "";
        int error = 0;
        int rest = 0;
        if (strXzqdmList != null && !strXzqdmList.equals("") && !strXzqdmList.equals("null")) {
            String[] list = strXzqdmList.split(",");
            if (list.length > 0) {
                for (int i = 0; i < list.length; i++) {
                    String xzqdm = list[i];
                    if (!xzqdm.equals("")) {
                        parm.put("xzqdm", xzqdm);

                        int cnt = wpzfNdhcHcdwService.getTbhcjglist(parm);
                        if (cnt == 0) {
                            List<Map<String, Object>> unitlist = wpzfNdhcHcdwService.get_dwhcrw_pf(parm);
                            if (unitlist != null && unitlist.size() > 0) {
                                ModelMap map = new ModelMap();
                                map.put("realname", parm.get("realname") + "");
                                map.put("username", parm.get("username") + "");
                                String fpsj = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss").format(new Date());
                                map.put("fpsj", fpsj);
                                map.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                                map.put("xzqdm", xzqdm);
                                map.put("pch", parm.get("pch") + "");
                                int c = wpzfNdhcHcdwService.update_pf_user(map);
                                if (c > 0) {
                                    rest++;
                                }
                            }
                        } else {
                            msg += xzqdm + "|";
                            error++;
                        }
                    }
                }
            }
        } else {
            return AjaxResult.error("请至少选择一个区县", -1);
        }

        if (rest > 0 && msg.equals("")) {
            return AjaxResult.error("任务批量调整成功,共分配******" + rest + "个******区县");
        } else if (rest > 0 && !msg.equals("")) {
            return AjaxResult.success("此次任务共成功调整******" + rest + "个区县，调整失败" + error + "（错误信息：" + msg + "已有核查成果）");
        }
        return AjaxResult.error("任务批量调整失败", -1);
    }



    /*单位负责人***************获取已分配的任务区县*/
    @Log(title = "单位负责人***************获取已分配的任务区县", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_yfp_tasklist", method = RequestMethod.POST)
    public AjaxResult get_unit_yfp_tasklist(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_yfp_tasklist(parm);
        if (rest != null) {
            return AjaxResult.success("获取本单位已分配的任务区县列表成功", rest, rest.size());
        }
        return AjaxResult.error("获取本单位已分配的任务区县列表失败", -1);
    }


    /*单位负责人***************获取已分配未做的任务区县列表成功*/
    @Log(title = "单位负责人***************获取已分配未做的任务区县列表成功", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_yfp_wz_tasklist", method = RequestMethod.POST)
    public AjaxResult get_unit_yfp_wz_tasklist(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        //获取当前用户所有已完成的任务
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_yfp_wz_tasklist(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_yfp_wz_tasklist_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取已分配未做的任务区县列表成功", rest, cnt);
        }

        return AjaxResult.error("获取已分配未做的任务区县列表失败", -1);
    }


    //导出
    @RequestMapping(value = "/export", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult export(@RequestBody Map<String, Object> parm, HttpServletResponse response) {
        ExcelUtils excel = new ExcelUtils();
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        String msg = "";
        String rest = "";
        String category = parm.get("category") + "";
        String xzqdm = parm.get("xzqdm") + "";
        List<String> Colomnlist = new ArrayList<>();
        try {
            parm.put("username", loginUser.getUsername());

            System.out.println(tempath);
            if (category.equals("任务情况统计（用户）")) {
                Colomnlist.clear();
                Colomnlist.add("序号");
                Colomnlist.add("所属省");
                Colomnlist.add("所属区县");
                Colomnlist.add("区县代码");
                Colomnlist.add("批次号");
                Colomnlist.add("图斑总数");
                Colomnlist.add("提交状态");
                Colomnlist.add("已核查图斑数量");
                Colomnlist.add("待确认图斑数量");
                Colomnlist.add("已确认图斑数量");
                List<Map<String, Object>> list = wpzfNdhcHcdwService.get_usertask_static(parm);
                rest = excel.export(response, category, list, Colomnlist, tempath);
            } else if (category.equals("本单位核查人员进度情况")) {
                parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                Colomnlist.clear();
                Colomnlist.add("序号");
                Colomnlist.add("用户名");
                Colomnlist.add("姓名");
                Colomnlist.add("任务区县总数");
                Colomnlist.add("已提交区县数量");
                Colomnlist.add("未提交区县数量");
                Colomnlist.add("已确认图斑数量");
                Colomnlist.add("待确认图斑数量");
                Colomnlist.add("整改图斑数量");
                List<Map<String, Object>> list = wpzfNdhcHcdwService.get_unit_static_user(parm);
                rest = excel.export(response, category, list, Colomnlist, tempath);
            } else if (category.equals("本单位核查进度情况")) {
                parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                Colomnlist.clear();
                Colomnlist.add("序号");
                Colomnlist.add("省份");
                Colomnlist.add("区县名称");
                Colomnlist.add("行政区代码");
                Colomnlist.add("任务图斑数量");
                Colomnlist.add("已核查图斑");
                Colomnlist.add("未核查图斑");
                Colomnlist.add("待确认图斑数量");
                Colomnlist.add("已确认图斑数量");
                Colomnlist.add("待整改图斑数量");
                Colomnlist.add("已整改图斑数量");
                List<Map<String, Object>> list = wpzfNdhcHcdwService.get_unit_static(parm);
                rest = excel.export(response, category, list, Colomnlist, tempath);
            }
            if (rest.contains("error")) {
                msg = "导出失败";
            } else {
                msg = "导出成功";
            }
            return AjaxResult.success(msg, rest);
        } catch (Exception e) {
            e.printStackTrace();
            msg = "导出失败";
        }
        return AjaxResult.error(msg, -1);
    }

    @RequestMapping(value = "/add_unit_user", method = RequestMethod.POST)
    public AjaxResult add_unit_user(@RequestBody Map<String, Object> parm) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date1 = new Date();
        String currentTime = dateFormat.format(date1);
        parm.put("fpsj", currentTime);
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());

        String xzqdmList = parm.get("xzqdm") + "";
        Integer rest = 0;
        if (xzqdmList.contains("|")) {
            String[] arryList = xzqdmList.split("\\|");
            if (arryList.length > 0) {
                for (int i = 0; i < arryList.length; i++) {
                    ModelMap map = new ModelMap();
                    map.put("realname", parm.get("realname") + "");
                    map.put("username", parm.get("username") + "");
                    String fpsj = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime());
                    map.put("fpsj", fpsj);
                    map.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                    map.put("xzqdm", arryList[i] + "");
                    map.put("pch", parm.get("pch") + "");
                    map.put("year", parm.get("year") + "");
                    rest = wpzfNdhcHcdwService.add_unit_user(map);
                }
                if (rest > 0) {
                    return AjaxResult.success("用户分配成功");
                }
            }
        } else {
            rest = wpzfNdhcHcdwService.add_unit_user(parm);
            if (rest > 0) {
                return AjaxResult.success("用户分配成功");
            }
        }
        return AjaxResult.error("用户分配失败", -1);
    }

    /*单位负责人***************图斑管理*/
    @Log(title = "单位负责人***************图斑管理", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_tbbhlist", method = RequestMethod.POST)
    public AjaxResult get_unit_tbbhlist(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_tbbhlist(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_tbbhlist_count(parm);
        if (rest != null) {
            return AjaxResult.success("单位负责人***************图斑管理 成功", rest, cnt);
        }
        return AjaxResult.error("单位负责人***************图斑管理 失败", -1);
    }

    /*单位负责人***************待确认图斑确认个数*/
    @Log(title = "单位负责人***************待确认图斑确认个数", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_not_confirmtbbhlist", method = RequestMethod.POST)
    public AjaxResult get_unit_not_confirmtbbhlist(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_not_confirmtbbhlist(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_not_confirmtbbhlist_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取本单位待确认图斑列表成功", rest, cnt);
        }

        return AjaxResult.error("获取本单位待确认图斑列表失败", -1);
    }

    /*单位负责人***************已确认图斑确认个数*/
    @Log(title = "单位负责人***************已确认图斑确认个数", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/get_unit_confirmtbbhlist", method = RequestMethod.POST)
    public AjaxResult get_unit_confirmtbbhlist(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.get_unit_confirmtbbhlist(parm);
        Integer cnt = wpzfNdhcHcdwService.get_unit_confirmtbbhlist_count(parm);
        if (rest != null) {
            return AjaxResult.success("获取本单位待确认图斑列表成功", rest, cnt);
        }

        return AjaxResult.error("获取本单位待确认图斑列表失败", -1);
    }

    //监理核查结果确认 查询所有省
    @Log(title = "监理核查结果确认 查询所有省", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getJlhcjgqrSheng", method = RequestMethod.POST)
    public AjaxResult getJlhcjgqrSheng(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getSysUser().getUserName());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.getJlhcjgqrSheng(parm);
        if (rest != null) {
            return AjaxResult.success("获取本单位待确认图斑列表成功", rest);
        }
        return AjaxResult.error("获取本单位待确认图斑列表失败", -1);
    }

    //监理核查结果确认 根据省查所有县
    @Log(title = "监理核查结果确认 根据省查所有县", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getJlhcjgqrXian", method = RequestMethod.POST)
    public AjaxResult getJlhcjgqrXian(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getSysUser().getUserName());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.getJlhcjgqrXian(parm);
        if (rest != null) {
            return AjaxResult.success("获取本单位待确认图斑列表成功", rest);
        }
        return AjaxResult.error("获取本单位待确认图斑列表失败", -1);
    }

    //监理核查结果确认 左側列表
    @Log(title = "监理核查结果确认 左側列表", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getJlhcjgqrLeftList", method = RequestMethod.POST)
    public AjaxResult getJlhcjgqrLeftList(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("username", loginUser.getSysUser().getUserName());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.getJlhcjgqrLeftList(parm);
        if (rest != null) {
            return AjaxResult.success("监理核查结果 左側列表 成功", rest);
        }
        return AjaxResult.error("监理核查结果 左側列表 失败", -1);
    }

    //单位负责人图斑管理 左侧列表
    @Log(title = "单位负责人图斑管理 左侧列表", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/dwUnitLeaderLeftList", method = RequestMethod.POST)
    public AjaxResult dwUnitLeaderLeftList(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.dwUnitLeaderLeftList(parm);
        if (rest != null) {
            return AjaxResult.success("监理核查结果确认 未確認提交 成功", rest);
        }
        return AjaxResult.error("监理核查结果确认 未確認提交失败", -1);
    }

    //根据文件名称查询信息
    @Log(title = "根据文件名称查询信息", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getWjXxTqjgByWjmc", method = RequestMethod.POST)
    public AjaxResult getWjXxTqjgByWjmc(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.getWjXxTqjgByWjmc(parm);
        if (rest != null) {
            return AjaxResult.success("根据文件名称查询信息 成功", rest);
        }
        return AjaxResult.error("根据文件名称查询信息 失败", -1);
    }

    /**
     * 地块数据分配单位
     */
    @Log(title = "分配单位", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/fpdw", method = RequestMethod.POST)
    public AjaxResult fpdw(@RequestBody Map<String, Object> parm) {
        Integer rest = wpzfNdhcHcdwService.fpdw(parm);
        if (rest > 0) {
            return AjaxResult.success("分配单位 成功", rest);
        } else if (rest == -1) {
            return AjaxResult.error("当前批次已存在数据", rest);
        }
        return AjaxResult.error("分配单位 失败", -1);
    }

    /**
     * 查询批次号
     */
    @Log(title = "查询批次号", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/queryFpdwPch", method = RequestMethod.POST)
    public AjaxResult queryFpdwPch(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.queryFpdwPch(parm);
        if (rest != null) {
            return AjaxResult.success("查询批次号 成功", rest);
        }
        return AjaxResult.error("查询批次号 失败", -1);
    }

    /**
     * 查询分配单位
     */
    @Log(title = "查询分配单位", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/queryHcrwfpdw", method = RequestMethod.POST)
    public AjaxResult queryHcrwfpdw(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.queryHcrwfpdw(parm);
        Integer cnt = wpzfNdhcHcdwService.queryHcrwfpdwCount(parm);

        if (rest != null) {
            return AjaxResult.success("查询分配单位 成功", rest, cnt);
        }
        return AjaxResult.error("查询分配单位 失败", -1);
    }


    //todo 单位管理员
    @RequestMapping(value = "/getBatchNumberList", method = RequestMethod.POST)
    public AjaxResult getBatchNumberList(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.getBatchNumberList(param);
        return AjaxResult.success("获取批次号", rest);
    }

    //筛选条件查询接口（省、县）
    @RequestMapping(value = "/getProvinceList", method = RequestMethod.POST)
    public AjaxResult getProvinceList(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.getProvinceList(param);
        return AjaxResult.success("获取省", rest);
    }

    @RequestMapping(value = "/getCountyList", method = RequestMethod.POST)
    public AjaxResult getCountyList(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.getCountyList(param);
        return AjaxResult.success("获取县", rest);
    }

    @RequestMapping(value = "/queryDkTaskList", method = RequestMethod.POST)
    public AjaxResult queryDkTaskList(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.queryDkTaskList(param);
        Integer cnt = wpzfNdhcHcdwService.queryDkTaskListCount(param);
        return AjaxResult.success("地块列表", rest, cnt);
    }

    //todo 单位管
    //pch
    @RequestMapping(value = "/getPch", method = RequestMethod.POST)
    public AjaxResult getPch(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_name", loginUser.getSysUser().getUserName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.getPch(param);
        return AjaxResult.success("获取批次号", rest);
    }

    //筛选条件查询接口（省、县）
    @RequestMapping(value = "/getSheng", method = RequestMethod.POST)
    public AjaxResult getSheng(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_name", loginUser.getSysUser().getUserName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.getSheng(param);
        return AjaxResult.success("获取省", rest);
    }

    @RequestMapping(value = "/getXian", method = RequestMethod.POST)
    public AjaxResult getXian(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_name", loginUser.getSysUser().getUserName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.getXian(param);
        return AjaxResult.success("获取县", rest);
    }

    //查询未完成、已完成行政区列表接口
    @RequestMapping(value = "/queryXzqTask", method = RequestMethod.POST)
    public AjaxResult queryXzqTask(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_name", loginUser.getSysUser().getUserName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.queryXzqTask(param);
        Integer cnt = wpzfNdhcHcdwService.queryXzqTaskCount(param);
        return AjaxResult.success("行政区列表", rest, cnt);
    }

    //查询未完成、已完成地块列表接口，查询区县内未完成的图斑
    @RequestMapping(value = "/queryDkTask", method = RequestMethod.POST)
    public AjaxResult queryDkTask(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_name", loginUser.getSysUser().getUserName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.queryDkTask(param);
        Integer cnt = wpzfNdhcHcdwService.queryDkTaskCount(param);
        return AjaxResult.success("地块列表", rest, cnt);
    }

    //数据提交
    @RequestMapping(value = "/submitdate", method = RequestMethod.POST)
    public AjaxResult submitdate(@RequestBody List<Map<String, Object>> params) {
        Integer rest = wpzfNdhcHcdwService.submitdate(params);
        if (rest > 0) {
            return AjaxResult.success("提交成功", rest);
        } else {
            return AjaxResult.error("提交失败", -1);
        }
    }

    //todo 单位确认
    //查询待确认、已确认地块任务列表
    @RequestMapping(value = "/queryQrDkTask", method = RequestMethod.POST)
    public AjaxResult queryQrDkTask(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_name", loginUser.getSysUser().getUserName());
        List<Map<String, Object>> rest = wpzfNdhcHcdwService.queryQrDkTask(param);
        Integer cnt = wpzfNdhcHcdwService.queryQrDkTaskCount(param);
        return AjaxResult.success("地块列表", rest, cnt);
    }

    //监理核查结果确认 未確認提交
    @RequestMapping(value = "/jlhcjgqrSubmit", method = RequestMethod.POST)
    public AjaxResult jlhcjgqrSubmit(@RequestBody List<Map<String, Object>> params) {
        Integer rest = wpzfNdhcHcdwService.jlhcjgqrSubmit(params);
        if (rest > 0) {
            return AjaxResult.success("待确认 提交成功", rest);
        } else {
            return AjaxResult.error("待确认 提交失败", -1);
        }
    }
}
